Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile for Mac M1/M2 with CC_BOOST #126

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ZiggerZZ
Copy link

The Makefile that I used to compile on Mac M2 (placed in ./examples/Makefile). I've changed boost-related constants and a few flags for compilation.

Note that you'll probably need to install a few packages through homebrew first.

One you make libdds.a, then you can create a dynamic library (shared object) using g++ -shared -o libdds.so -Wl,-all_load libdds.a -L/opt/homebrew/Cellar/boost/1.81.0_1/lib -lboost_system -lboost_thread-mt.

# This is a Makefile for the examples,
# for Mac and the clang compiler.

# It does assume a Unix-like setup for some commands,
# but if you only want to call "make" with the default target,
# you should be OK.

# If your compiler name is not given here, change it.
CC		= g++

CC_FLAGS	= -O3 -flto -mtune=generic

CC_BOOST      = /opt/homebrew/Cellar/boost/1.81.0_1
CC_BOOST_INCL = $(CC_BOOST)/include
CC_BOOST_LIB  = $(CC_BOOST)/lib
CC_BOOST_LINK = -L$(CC_BOOST_LIB) -lboost_system -lboost_thread-mt

# These flags are not turned on by default, but DDS should pass them.
# Turn them on below.
WARN_FLAGS	= 		\
	-Wshadow 		\
	-Wsign-conversion 	\
	-pedantic -Wall -Wextra  \
	-Wcast-align -Wcast-qual \
	-Wctor-dtor-privacy 	\
	-Wdisabled-optimization \
	-Winit-self 		\
	-Wmissing-declarations 	\
	-Wmissing-include-dirs 	\
	-Wcomment 		\
	-Wold-style-cast 	\
	-Woverloaded-virtual 	\
	-Wredundant-decls 	\
	-Wsign-promo 		\
	-Wstrict-overflow=1 	\
	-Wswitch-default -Wundef \
	-Werror 		\
	-Wno-unused 		\
	-Wno-unknown-pragmas 	\
	-Wno-long-long		\
	-Wno-format

# Here you can turn on warnings.
# CC_FULL_FLAGS	= $(CC_FLAGS)
CC_FULL_FLAGS	= $(CC_FLAGS) $(WARN_FLAGS)

DLLBASE		= dds
STATIC_LIB	= lib$(DLLBASE).a

COMMON_SOURCE_FILES 	=	\
	hands.cpp

ALL_EXAMPLE_FILES	=	\
	AnalysePlayBin		\
	AnalysePlayPBN		\
	AnalyseAllPlaysBin	\
	AnalyseAllPlaysPBN	\
	CalcDDtable.cpp		\
	CalcDDtablePBN.cpp	\
	CalcAllTables.cpp	\
	CalcAllTablesPBN.cpp	\
	DealerPar.cpp		\
	Par.cpp			\
	SolveBoard.cpp		\
	SolveBoardPBN.cpp	\
	SolveAllBoards.cpp

LIB_FLAGS	= -L. -l$(DLLBASE) $(CC_BOOST_LINK)

OBJ_FILES	= $(subst .cpp,.o,$(COMMON_SOURCE_FILES))
EX_OBJ_FILES	= $(subst .cpp,.o,$(ALL_EXAMPLE_FILES))
EX_EXE_FILES	= $(subst .cpp,,$(ALL_EXAMPLE_FILES))

AnalysePlayBin:	$(OBJ_FILES) AnalysePlayBin.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) AnalysePlayBin.o -o AnalysePlayBin

AnalysePlayPBN:	$(OBJ_FILES) AnalysePlayPBN.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) AnalysePlayPBN.o -o AnalysePlayPBN

AnalyseAllPlaysBin:	$(OBJ_FILES) AnalyseAllPlaysBin.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) AnalyseAllPlaysBin.o -o AnalyseAllPlaysBin

AnalyseAllPlaysPBN:	$(OBJ_FILES) AnalyseAllPlaysPBN.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) AnalyseAllPlaysPBN.o -o AnalyseAllPlaysPBN

CalcDDtable:	$(OBJ_FILES) CalcDDtable.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) CalcDDtable.o -o CalcDDtable

CalcDDtablePBN:	$(OBJ_FILES) CalcDDtablePBN.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) CalcDDtablePBN.o -o CalcDDtablePBN

CalcAllTables:	$(OBJ_FILES) CalcAllTables.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) CalcAllTables.o -o CalcAllTables

CalcAllTablesPBN:	$(OBJ_FILES) CalcAllTablesPBN.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) CalcAllTablesPBN.o -o CalcAllTablesPBN

DealerPar:	$(OBJ_FILES) DealerPar.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) DealerPar.o -o DealerPar

Par:	$(OBJ_FILES) Par.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) Par.o -o Par

SolveBoard:	$(OBJ_FILES) SolveBoard.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) SolveBoard.o -o SolveBoard

SolveBoardPBN:	$(OBJ_FILES) SolveBoardPBN.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) SolveBoardPBN.o -o SolveBoardPBN

SolveAllBoards:	$(OBJ_FILES) SolveAllBoards.o
	$(CC) $(CC_FULL_FLAGS) $(LD_FLAGS) $(LIB_FLAGS) $(OBJ_FILES) SolveAllBoards.o -o SolveAllBoards

%.o:	%.cpp
	$(CC) $(CC_FULL_FLAGS) -c $< -o $*.o

depend:
	makedepend -Y -- $(COMMON_SOURCE_FILES) $(ALL_EXAMPLE_FILES)

clean:
	rm -f *.o $(EX_EXE_FILES) $(STATIC_LIB)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant